/*
 * DrawLinesCommand.cpp
 *
 *  Created on: 21/12/2011
 *      Author: Tales
 */

#include "DrawLinesCommand.hpp"
#include "PictureState.hpp"
#include "Layer.hpp"
#include "../graphics.hpp"

namespace yep
{
DrawLinesCommand::DrawLinesCommand(const vector<pair<int, int> > &pos , const Color & color_, int layer_) :
		Command(color_, layer_), positions(pos)
{
}

void yep::DrawLinesCommand::execute(PictureState & picture)
{
	Layer &layer = picture.getLayer(getLayerIndex());
	Graphics g(layer.getSurface());
	g.setColor(getColor());
	auto old = positions.begin();
	for (auto it = old + 1; it != positions.end(); ++it)
	{
		g.drawLine(*old, *it);
		old = it; // Apagar este para obter um efeito bonitinho
	}
}

/* namespace yep */
}

